﻿<template>
	<div class="card-fill layout-padding" v-loading="loading" element-loading-text="Loading...">
		<el-card shadow="hover" class="layout-padding-auto create-form">
			<el-form ref="formRef" :model="stateData.vmModel" label-width="120px">
				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>基本信息</span>
					</div>

					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_StaffNeedEntryId_FormItem" prop="Entity.StaffNeedEntryId">
								<template #label>
									<WtmLabelTooltip label="用人需求子表" tooltip="关联的用人需求子表" />
								</template>
								<el-select v-model="stateData.vmModel.Entity.StaffNeedEntryId" disabled clearable class="width100">
									<el-option
										v-for="item in stateData.AllSysHrStaffNeedRequestBillEntrys"
										:key="item.Value"
										:value="item.Value"
										:label="item.Text"
									></el-option
								></el-select>
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item
								ref="Entity_HrStatus_FormItem"
								prop="Entity.HrStatus"
								:rules="[{ required: true, message: '状态为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="状态" tooltip="单据状态" />
								</template>
								<el-select v-model="stateData.vmModel.Entity.HrStatus" disabled clearable class="width100">
									<el-option key="申请中" value="申请中" label="申请中"></el-option>
									<el-option key="已审核" value="已审核" label="已审核"></el-option>
									<el-option key="已拒绝" value="已拒绝" label="已拒绝"></el-option>
									<el-option key="已面试" value="已面试" label="已面试"></el-option>
									<el-option key="面试通过" value="面试通过" label="面试通过"></el-option>
									<el-option key="面试未通过" value="面试未通过" label="面试未通过"></el-option>
									<el-option key="体检中" value="体检中" label="体检中"></el-option>
									<el-option key="体检通过" value="体检通过" label="体检通过"></el-option>
									<el-option key="体检未通过" value="体检未通过" label="体检未通过"></el-option>
									<el-option key="背调中" value="背调中" label="背调中"></el-option>
									<el-option key="背调通过" value="背调通过" label="背调通过"></el-option>
									<el-option key="背调未通过" value="背调未通过" label="背调未通过"></el-option>
									<el-option key="Offer已发" value="Offer已发" label="Offer已发"></el-option>
									<el-option key="Offer已接受" value="Offer已接受" label="Offer已接受"></el-option>
									<el-option key="Offer已拒绝" value="Offer已拒绝" label="Offer已拒绝"></el-option>
									<el-option key="已录用" value="已录用" label="已录用"></el-option>
									<el-option key="已入职" value="已入职" label="已入职"></el-option>
									<el-option key="已报到" value="已报到" label="已报到"></el-option>
									<el-option key="入职资料待完善" value="入职资料待完善" label="入职资料待完善"></el-option>
									<el-option key="试用中" value="试用中" label="试用中"></el-option>
									<el-option key="已转正" value="已转正" label="已转正"></el-option>
									<el-option key="已放弃" value="已放弃" label="已放弃"></el-option>
									<el-option key="已淘汰" value="已淘汰" label="已淘汰"></el-option>
									<el-option key="离职办理中" value="离职办理中" label="离职办理中"></el-option>
									<el-option key="已离职" value="已离职" label="已离职"></el-option
								></el-select>
							</el-form-item>
						</el-col>
					</el-row>
				</div>

				<div style="text-align: right">
					<WtmButton @click="onClose" type="default" :button-text="$t('message._system.common.vm.cancel')" style="margin-top: 15px" />
				</div>
			</el-form>
		</el-card>
	</div>
</template>

<script setup lang="ts" name="message._system.common.vm.edit;false">
import { reactive, ref, getCurrentInstance, onMounted } from 'vue';
import { SysHrStaffPoolApi as api } from '/@/views/hr/syshrstaffpool/api';
import other from '/@/utils/other';
import { useRouter } from 'vue-router';
import { ISysHrStaffPoolVm } from '/@/views/hr/syshrstaffpool/api/interface';
import { IViewModel } from '/@/types/common';

const ci = getCurrentInstance() as any;
const loading = ref(false);
// 定义变量内容
const formRef = ref();
const stateData = reactive<IViewModel<ISysHrStaffPoolVm>>({
	vmModel: {
		Entity: {
			ID: null,
			HrStatus: 0,
		},
	},

	AllSysHrStaffNeedRequestBillEntrys: [] as any[],
});

// 取消
const onClose = () => {
	closeDialog();
};

// 页面加载时
onMounted(() => {
	loading.value = true;
	if (ci.attrs['wtmdata']) {
		stateData.vmModel.Entity.ID = ci.attrs['wtmdata'].ID;
	} else if (useRouter().currentRoute.value.query.id) {
		stateData.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	const promises: Promise<any>[] = [
		other.getSelectList('/api/SysHrStaffPool/GetSysHrStaffNeedRequestBillEntrys', [], false).then((x) => {
			stateData.AllSysHrStaffNeedRequestBillEntrys = x;
		}),

		api()
			.get(stateData.vmModel.Entity.ID ?? '')
			.then((data: any) => other.setValue(stateData.vmModel, data)),
	];
	Promise.allSettled(promises).finally(() => {
		loading.value = false;
	});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh', 'closeDialog', 'updateHeaderButtons']);
// 关闭弹窗
const closeDialog = () => {
	emit('closeDialog');
};
</script>
